home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgramD2.iso / Borland / Borland C++ V5.02 / STDLIB.PAK / FIND_F_O.CPP < prev    next >
C/C++ Source or Header  |  1997-05-06  |  858b  |  35 lines

  1.  #include <vector>
  2.  #include <iterator>
  3.  #include <algorithm>
  4.  
  5.  using namespace std;
  6.  
  7.  int main()
  8.  {
  9.    typedef vector<int>::iterator iterator;
  10.    int d1[10] = {0,1,2,2,3,4,2,2,6,7};
  11.    int d2[2] = {6,4};
  12.    //
  13.    // Set up two vectors.
  14.    //
  15.    vector<int> v1(d1+0, d1+10), v2(d2+0, d2+2);
  16.    //
  17.    // Try both find_first_of variants.
  18.    //
  19.    iterator it1 = find_first_of(v1.begin(), v1.end(), v2.begin(), v2.end());
  20.  
  21.    find_first_of(v1.begin(), v1.end(), v2.begin(), v2.end(), equal_to<int>());
  22.    //
  23.    // Output results.
  24.    //
  25.    cout << "For the vectors: ";
  26.    copy(v1.begin(),v1.end(), ostream_iterator<int>(cout," " ));
  27.    cout << " and ";
  28.    copy(v2.begin(),v2.end(), ostream_iterator<int>(cout," " ));
  29.    cout << endl << endl
  30.        << "both versions of find_first_of point to: "
  31.        << *it1;
  32.  
  33.    return 0;
  34.  }
  35.